package main

import "fmt"

//func swap(a int, b int) {
//	var temp int
//	temp = a
//	a = b
//	b = temp
//}

func swap(pa *int, pb *int) {
	var temp int
	temp = *pa // temp = main::a
	*pa = *pb  // main::a = main::b
	*pb = temp // main::b = temp

	fmt.Println("*pa = ", pa, " *pb = ", pb)
	fmt.Println("pa = ", *pa, " pb = ", *pb)
}

func main() {

	var a int = 10
	var b int = 20

	fmt.Println("a = ", &a, " b = ", &b)

	swap(&a, &b)
	fmt.Println("a=", a, "b=", b)

	var p *int

	p = &a
	fmt.Println(&a)
	fmt.Println(p)

	var pp **int // 二级指针

	pp = &p
	fmt.Println(&p)
	fmt.Println(pp)

	var ppp ***int // 三级指针
	ppp = &pp
	fmt.Println(&pp)
	fmt.Println(ppp)

}
